<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>添加渠道</title>
	<jsp:include page="../inc.jsp"></jsp:include>
</head>
<body>
	<h2>添加渠道信息</h2>
	<div style="margin:20px 0;" ></div>
	<div class="easyui-panel" title="添加渠道" style="width:35%">
		<div style="padding:10px 60px 20px 60px">
	    <form id="ff" method="post" >
	    	<table>
	    		<tr>
	    			<td>用户名:</td>
	    			<td><input class="easyui-span2" id="YHM" type="text" name="YHM"  data-options="required:true"></input>&nbsp;&nbsp;&nbsp;</td>
	    		</tr>
	    		<tr>
	    			<td>密码:</td>
	    			<td><input class="easyui-span2" id="MIMA" type="text" name="MIMA" data-options="required:true,validType:'email'"></input></td>
	    		</tr>
	    		<tr>
	    			<td>类别:</td>
	    			<td><input class="easyui-span2" type="text" name="LEIBIE" data-options="required:true"></input></td>
	    		</tr>
	    		<tr>
	    			<td>IP:</td>
	    			<td><input class="easyui-span2" type="text" name="IP" data-options="required:true"></input></td>
	    		<tr>
	    			<td>渠道名称:</td>
	    			<td><input class="easyui-span2" type="text" name="QDMC" data-options="required:true"></input></td>
	    		</tr>
	    	</table>
	    </form>
	    <div style="text-align:center;padding:5px">
	    	<a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">确认添加</a>
	    	<a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()">重置</a>
	    </div>
	    </div>
	</div>
	<script>
		function submitForm(){
		if($("#YHM").val()!="" && $("#MIMA").val()!=""){
			$.ajax({
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "${pageContext.request.contextPath}/qdglController/add.shtml",//url
                data: $('#ff').serialize(),
	                success: function (result) {
	                    console.log(result);//打印服务端返回的数据(调试用)        
	                      parent.$.messager.confirm('提示', '添加成功');
	                      $('#ff').form('clear');
                	},
	                error : function() {
	                    parent.$.messager.confirm('提示', '添加失败！');
	                }
           	});
            }else{
	            parent.$.messager.confirm('提示', '添加失败,用户名或密码不能为空！');
	            	$('#ff').form('clear');
			}
		}
		function clearForm(){
			$('#ff').form('clear');
		}
	</script>
</body>
</html>